﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ import Namespace="Common.Background.Entity" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    职员列表
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h1>
        <%= Html.ActionLink("职员管理", "WebManageUserList", "System")%>-职员列表</h1>
    <div>
        <div>
            <table width="100%" cellspacing="1" cellpadding="3" class="chaxun_table">
                <tr>
                    <td>
                        <label for="DepartmentID">
                            部门：</label>
                        <%=Html.DropDownList("DepartmentID", ViewData["Dept"] as SelectList) %>&nbsp;&nbsp;
                        <label for="RoleID">
                            职位：</label>
                        <%=Html.DropDownList("RoleID", ViewData["Role"] as SelectList)%>&nbsp;&nbsp;
                        <label for="name">
                            登录名或姓名：</label><input id="name" name="name" value="<%=ViewData["name"]%>" />
                        <button type="submit" class="button" id="search">
                            查询</button>
                    </td>
                </tr>
            </table>
        </div>
        <%Html.RenderPartial("WebManageUser", ViewData["WebManageUserList"]);%>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <script src="../../Scripts/liebiao_table.js" type="text/javascript"></script>
    <script type="text/javascript">
        /// <reference path="../../xheditor/xheditor-zh-cn.min.js" />

        $(function () {

            //选择部门时，职位联动
            $("#DepartmentID").change(function () {
                var deptId = $("#DepartmentID").val()
                $("#RoleID>option").remove();
                $.ajax({
                    type: 'POST',
                    url: "/system/GetRole",
                    data: 'DeptId=' + deptId,
                    success: function (json) {
                        $("#RoleID").append("<option value='-1'>全部</option>");
                        if (json.list.length > 0) {
                            $.each(json.list, function (i, o) {
                                $("#RoleID").append("<option value='" + o.ManageRoleID + "'>" + o.RoleName + "</option>");
                            });
                        }
                    }
                });

            });
            var urlParam = location.href.split('?');
            if (urlParam.length > 1)
                urlParam = urlParam[1].split('&'); //得到URL数组
            //搜索
            $("#search").click(function () {
                var departmentID = $("#DepartmentID").val();
                var roleID = $("#RoleID").val();
                var name = $("#name").val();
                location.href = '/system/WebManageUserList?pi=' + $('#pageindex').val() + '&departmentID=' + departmentID + '&roleID=' + roleID + '&name=' + name;


            });

            //删除
            $('#del').click(function () {
                var checkeds = $('.liebiao_table').find('tbody').find('input[type=checkbox][checked=true]');
                var ids = '';
                $.each(checkeds, function (i, o) {
                    if (i == 0)
                        ids += $(o).val();
                    else
                        ids += ',' + $(o).val();
                });
                if (ids == '') {
                    alert('请选择要删除项');
                    return false;
                } else {


                    $.ajax({
                        type: "POST",
                        url: "/system/delete",
                        data: "pi=" + $('#pageindex').val() + "&idd=" + ids,
                        success: function (data) {
                            alert("删除成功");
                            location.href = location.href;

                        }
                    });

                }
            })
            //冻结
            $('#Freeze').click(function () {
                var checkeds = $('.liebiao_table').find('tbody').find('input[type=checkbox][checked=true]');
                var ids = '';
                $.each(checkeds, function (i, o) {
                    if (i == 0)
                        ids += $(o).val();
                    else
                        ids += ',' + $(o).val();
                });
                if (ids == '') {
                    alert('请选择要冻结的项');
                    return false;
                } else {
                    $.ajax({
                        type: "POST",
                        url: "/system/Freeze",
                        data: "pi=" + $('#pageindex').val() + "&idd=" + ids,
                        success: function (data) {
                            alert("冻结成功");
                            location.href = location.href;

                        }
                    });

                }
            })
            //冻结
            $('#NotFreeze').click(function () {
                var checkeds = $('.liebiao_table').find('tbody').find('input[type=checkbox][checked=true]');
                var ids = '';
                $.each(checkeds, function (i, o) {
                    if (i == 0)
                        ids += $(o).val();
                    else
                        ids += ',' + $(o).val();
                });
                if (ids == '') {
                    alert('请选择要解冻的项');
                    return false;
                } else {
                    $.ajax({
                        type: "POST",
                        url: "/system/NotFreeze",
                        data: "pi=" + $('#pageindex').val() + "&idd=" + ids,
                        success: function (data) {
                            alert("解冻成功");
                            location.href = location.href;
                        }
                    });
                }

            })


        });

   
     
    </script>
</asp:Content>
